package cz.boxdesign.library.umgr.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

import cz.boxdesign.library.umgr.domain.AuthentificatedUserDTO;

@Service("userServiceAssembler")
public class UserServiceAssemblerImpl implements UserServiceAssembler {

  @Override
  public UserDetails buildAuthenticatedUserDTOFromUser(User user, String displayName, String userId) {
    UserDetails ud = new AuthentificatedUserDTO(user.getUsername(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(), user
        .isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities(), displayName, userId);
    return ud;
  }

}
